// pages/shoucang/index.js
// pages/order/order.js
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    currtab: 0,
    swipertab: [{ name: '文章', index: 0 }, { name: '视频', index: 1 }, { name: '商品', index: 2 }],
  },
 

  godetail:function(e){
    wx.setStorage({
      key: "detail",
      data: this.data.alreadyOrder[e.currentTarget.id]
    }),
    wx.navigateTo({
      url: '/pages/article/zhishi/zhishi',
    })
  },

  govideo:function(e){
   var data= [this.data.waitPayOrder[e.currentTarget.id]]
   console.log(data);
    wx.navigateTo({
      url: `/pages/video/display/display?data=${JSON.stringify(data)}`,
    })  
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
 
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    // 页面渲染完成
    this.getDeviceInfo()
    this.orderShow()
  },
 
  getDeviceInfo: function () {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          deviceW: res.windowWidth,
          deviceH: res.windowHeight
        })
      }
    })
  },
 
  /**
  * @Explain：选项卡点击切换
  */
  tabSwitch: function (e) {
    var that = this
    if (this.data.currtab === e.target.dataset.current) {
      return false
    } else {
      that.setData({
        currtab: e.target.dataset.current
      })
    }
  },
 
  tabChange: function (e) {
    this.setData({ currtab: e.detail.current })
    this.orderShow()
  },
 
  orderShow: function () {
    let that = this
    switch (this.data.currtab) {
      case 0:
        that.alreadyShow()
        break
      case 1:
        that.waitPayShow()
        break
      case 2:
        that.lostShow()
        break
    }
  },
  alreadyShow: function(){
    wx.request({
      url: 'http://localhost:9000/article/collect',
      method: "GET",
      success:(res)=>{
        this.setData({
          alreadyOrder: res.data
        })
      }
    })
  },
 
  waitPayShow:function(){
    wx.request({
      url: 'http://localhost:9000/video/getByCollect',
      method: "GET",
      success:(res)=>{
        this.setData({
          waitPayOrder: res.data
        })
      }
    })
  },
 
  lostShow: function () {
    this.setData({
      lostOrder: [{ name: "AdidasKAPTIR跑步男鞋",  neirong: "精彩的缓震技术", money: "399.9", url: "/images/篮球鞋b1.png",url1:"" }],
    })
  },
 
  
})